package ge.telasi.tasks.ui.flowpermission;

import ge.telasi.tasks.model.FlowPermission;
import ge.telasi.tasks.ui.task.TaskDecontationUtils;
import static ge.telasi.tasks.ui.flowpermission.FlowPermissionDecorationUtils.*;
import static ge.telasi.tasks.ui.task.TaskDecontationUtils.*;

/**
 * @author dimitri
 */
public class FlowPermissionPropertiesPanel extends javax.swing.JPanel {
    private static final long serialVersionUID = 5488081570997713705L;

    public FlowPermissionPropertiesPanel() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        lblOperation = new javax.swing.JLabel();
        lblRole = new javax.swing.JLabel();
        lblInitStat = new javax.swing.JLabel();
        lblFinalStat = new javax.swing.JLabel();

        jLabel1.setText("ოპერაცია:");

        jLabel2.setText("როლი:");

        jLabel3.setText("დავალების სტატუსი:");

        jLabel4.setText("საბოლოო სტატუსი:");

        lblOperation.setBackground(java.awt.Color.white);
        lblOperation.setText("operation");

        lblRole.setBackground(java.awt.Color.white);
        lblRole.setText("role");

        lblInitStat.setText("task status");

        lblFinalStat.setText("final status");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblRole, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                    .addComponent(lblOperation, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                    .addComponent(lblInitStat, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                    .addComponent(lblFinalStat, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lblOperation))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(lblRole))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(lblInitStat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(lblFinalStat))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    public void setFlowPermission(FlowPermission permission) {
        lblOperation.setText(getOperationName(permission.getOperation()));
        lblOperation.setIcon(getOperationIcon(permission.getOperation()));
        lblRole.setText(TaskDecontationUtils.getRoleLocalizedName(permission.getRole()));
        lblInitStat.setText(getStatusName(permission.getTaskStatus()));
        lblInitStat.setIcon(getStatusIcon(permission.getTaskStatus()));
        if (permission.getFinalStatus() != null) {
            lblFinalStat.setText(getStatusName(permission.getFinalStatus()));
            lblFinalStat.setIcon(getStatusIcon(permission.getFinalStatus()));
        } else {
            lblFinalStat.setText("--");
            lblFinalStat.setIcon(null);
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel lblFinalStat;
    private javax.swing.JLabel lblInitStat;
    private javax.swing.JLabel lblOperation;
    private javax.swing.JLabel lblRole;
    // End of variables declaration//GEN-END:variables

}
